package com.woniuxy.educationplatform.service.impl;

import com.alibaba.druid.sql.dialect.oracle.ast.stmt.OracleSelectRestriction;
import com.woniuxy.educationplatform.bean.GoodsBean;
import com.woniuxy.educationplatform.bean.OrderBean;
import com.woniuxy.educationplatform.mapper.OrderMapper;
import com.woniuxy.educationplatform.service.IOrderService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Transactional(readOnly = true)
@Service
public class OrderServiceImpl implements IOrderService {
    @Resource
    private OrderMapper orderMapper;
    @Override
    public OrderBean findById(Long id) {
        return orderMapper.findById(id);
    }
    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    @Override
    public int addOrder(OrderBean orderBean) {
        return orderMapper.addOrder(orderBean);
    }

    @Override
    public List<OrderBean> findByPage(int index, int nums) {
        return orderMapper.findByPage(index,nums);
    }
    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    @Override
    public int update(OrderBean orderBean) {
        return orderMapper.update(orderBean);
    }

    @Override
    public Map<String,Double> findOrderDetailsByStudentId(Long id) {
        return orderMapper.findOrderDetailsByStudentId(id);
    }

    @Override
    public int count() {
        return orderMapper.count();
    }

    @Override
    public List<OrderBean> findByCondition(OrderBean orderBean) {
        return orderMapper.findByCondition(orderBean);
    }

    @Override
    public List<GoodsBean> findByOrderId(Long id) {
        return orderMapper.findByOrderId(id);
    }

    @Override
    public int[] findNumsByOrderId(Long id) {
        return orderMapper.findNumsByOrderId(id);
    }

    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    @Override
    public void changeMoney(Long id, Double money) {
        orderMapper.changeMoney(id,money);
    }
}
